/**
 * 创建真正dom
 * @param {*} vnode 
 */
export function createElement(vnode) {
    let domNode = document.createElement(vnode.sel);

    if (vnode.text != '' && (vnode.children == undefined || vnode.children.length == 0)) {
        domNode.innerText = vnode.text;
    } else if (Array.isArray(vnode.children) && vnode.children.length > 0) {
        //有子节点
        for (let i = 0; i < vnode.children.length; i++) {
            let ch = vnode.children[i];
            let chDom = createElement(ch);
            //虚拟dom上树
            domNode.appendChild(chDom);
        }

    }
    //补充elm属性
    vnode.elm = domNode;
    return vnode.elm;
};